﻿using AbpProjectTemplate.Components.Auditing;
using AbpProjectTemplate.Components.Authorization;
using AbpProjectTemplate.Components.Configuration;

namespace AbpProjectTemplate.Application
{
    public abstract class AutoSettingsApplicationService<TSettings> : ApplicationService
        where TSettings : AutoSettingsBase<TSettings>
    {
        private readonly TSettings _settings;

        public AutoSettingsApplicationService(TSettings settings)
        {
            this._settings = settings;
        }

        /// <summary>
        /// 获取系统配置
        /// </summary>
        public virtual TSettings Get()
        {
            return this._settings;
        }
        /// <summary>
        /// 修改系统配置
        /// </summary>
        [ManagerAuthorize(AppPermissions.System.SystemConfig)]
        [AppAudited("修改")]
        public virtual void Update(TSettings settings)
        {
            this.ObjectMapper.Map(settings, this._settings);
        }
    }
}
